//index.js
//获取应用实例
const app = getApp();
const md5 = require('../../utils/md5.js');
const http = require('../../utils/http.js');
Page({
  data: {
     line:'eee',
     imgstate:'none',
     inputValue:'',
     inputNext:'',
     ishref:'false'
  },
 
  onLoad: function () {
    
  },
  clickfocus(){
      this.setData({
          line:'2b93f6',
          imgstate:'inline-block' 
        })
  },
  clickblur(e){
      console.log(e);
      let mobile = e.detail.value;
      this.setData({
          line: 'eee',
          imgstate: 'none' 
      })
      if (mobile.length == 0) {
          wx.showToast({
              title: '请输入手机号！',
              
              duration: 1500
          })
          this.setData({
              inputNext: ''
          })
          return false;
      }
      if (mobile.length != 11) {
          wx.showToast({
              title: '手机号长度有误！',
              duration: 1500
          })
          this.setData({
              inputNext: ''
          })
          return false;
      }
      var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
      if (!myreg.test(mobile)) {
          wx.showToast({
              title: '手机号有误！',
              icon: 'success',
              duration: 1500
          })
          this.setData({
              inputNext: ''
          })
          return false;
      }
      this.setData({
          inputNext:'bgline'
      })
      return true;
  },
  clickClear(e){
      this.setData({
          inputValue: '',
      })
  },
  clickInput(e){
      let phoneMsg = e.detail.value; 
      //console.log(e)    
      var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
      if (myreg.test(phoneMsg)) {
          this.setData({
              inputNext: 'bgline',
              ishref:'true'
          })
          wx.setStorageSync('myPhone', phoneMsg )
          this.setData({
              inputValue: phoneMsg,
              
          })
      }else{
          this.setData({
              inputNext: '',
              ishref: 'false'
          }) 
      }
  }, 
  next(){
    wx.navigateTo({
      url: '/pages/logs/logs?phone=' + this.data.inputValue,
    })
   
  }
  
})
